<page-header [action]="phActionTpl">
  <ng-template #phActionTpl>
    <button nz-button nzType="primary" (click)="treeTable.collapseAll()">全部收起</button>
    <button nz-button nzType="primary" (click)="treeTable.expandAll()">全部展开</button>
    <button nz-button nzType="primary" (click)="addDepartment()">新建部门</button>
  </ng-template>
</page-header>

<app-treetable #treeTable [data]="'/sys/department'" [columns]="columns">
  <ng-template tree-row="action" let-item>
    <div style="display: flex;gap: 10px;">
      <a nz-button nzType="link" (click)="addDepartment(item)">添加下级部门</a>
      <a nz-button nzType="link" (click)="modify(item)">编辑</a>
      <a nz-button nzType="link" nzDanger (click)="delete(item.id)">删除</a>
    </div>
  </ng-template>
  <ng-template tree-row="name" let-item let-index="index">
    {{ item.name }}
    <i *ngIf="item?.extra?.dingDepId" nz-icon nzType="dingtalk" nzTheme="outline" style="font-size: 15px; color: #0a77ff"></i>
  </ng-template>
</app-treetable>

<ng-template #addDepartmentTemplate let-item>
  <sf #sf mode="default" [schema]="schema" [ui]="ui" [formData]="item" [cleanValue]="true" button="none" compact class="m-lg"> </sf>
</ng-template>
